var tab = {
	load : function(url, filter) {
		var path = window.location.pathname;
		var q = window.location.search;
		var dispatch = q.match(/^\?dispatch=[\w]+/);
		var sep = url.indexOf("?") >= 0 ? "&" : "?";
		var q1 = q.replace(/^\?dispatch=[\w]+&/, "");
		
		if((path.indexOf('NewApp.do') >= 0) && dispatch.length > 0){
			if(dispatch[0] == "?dispatch=init" && url != '/NewApp.do?dispatch=init') {
				$('input#click_redirect').val(url);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=match_trace" && url != '/NewApp.do?dispatch=match_trace') {
				$('input#click_redirect').val(url);
				$('button#submit').click();
			}
			else if((dispatch[0] == "?dispatch=supporting_document" || dispatch[0] == "?dispatch=supporting_document_upload") && url != '/NewApp.do?dispatch=supporting_document') {
				$('button#submit').click();
				window.location.href = jq_main_url + url + sep + q1;
			}
			else if(dispatch[0] == "?dispatch=document_checklist" && url != '/NewApp.do?dispatch=document_checklist') {
				$('input#click_redirect').val(url);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=outlet_detail" && url != '/NewApp.do?dispatch=outlet_detail') {
				$('input#click_redirect').val(url);
				$('input#click_filter').val(filter);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=outlet_create" && url != '/NewApp.do?dispatch=outlet_create') {
				$('input#click_redirect').val(url);
				$('input#click_filter').val(filter);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=payment_info" && url != '/NewApp.do?dispatch=payment_info') {
				$('input#click_redirect').val(url);
				$('input#click_filter').val(filter);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=statement_option" && url != '/NewApp.do?dispatch=statement_option') {
				$('input#click_redirect').val(url);
				$('input#click_filter').val(filter);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=other_info" && url != '/NewApp.do?dispatch=other_info') {
				$('input#click_redirect').val(url);
				$('input#click_filter').val(filter);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=physical_address" && url != '/NewApp.do?dispatch=physical_address') {
				$('input#click_redirect').val(url);
				$('input#click_filter').val(filter);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=payment_address" && url != '/NewApp.do?dispatch=payment_address') {
				$('input#click_redirect').val(url);
				$('input#click_filter').val(filter);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=correspondence_address" && url != '/NewApp.do?dispatch=correspondence_address') {
				$('input#click_redirect').val(url);
				$('input#click_filter').val(filter);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=mdr_form" && url != '/NewApp.do?dispatch=mdr_form') {
				$('input#click_redirect').val(url);
				$('input#click_filter').val(filter);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=recom_approval" && url != '/NewApp.do?dispatch=recom_approval') {
				$('button#submit').click();
				window.location.href = jq_main_url + url + sep + q1;
				
			}
			else if(dispatch[0] == "?dispatch=vendor_pos" && url != '/NewApp.do?dispatch=vendor_pos') {
				$('input#click_redirect').val(url);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=vendor_installation" && url != '/NewApp.do?dispatch=vendor_installation') {
				$('input#click_redirect').val(url);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=esa_pl" && url != '/NewApp.do?dispatch=esa_pl') {
				
				$('input#click_redirect').val(url);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=non_esa_pl" && url != '/NewApp.do?dispatch=non_esa_pl') {
				
				$('input#click_redirect').val(url);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=esa_ezypay" && url != '/NewApp.do?dispatch=esa_ezypay') {
				$('input#click_redirect').val(url);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=non_esa_ezypay" && url != '/NewApp.do?dispatch=non_esa_ezypay') {
				$('input#click_redirect').val(url);
				$('button#submit').click();
			}
			else if(dispatch[0] == "?dispatch=terminal_vendor_installation" && url != '/NewApp.do?dispatch=terminal_vendor_installation') {
				window.location.href = jq_main_url + url;
			}
			else if(dispatch[0] == "?dispatch=vendor_pos_3" && url != '/NewApp.do?dispatch=vendor_pos_3') {
				window.location.href = jq_main_url + url;
			}
			
		} else {
			window.location.href = jq_main_url + url + sep + q1;
		}
		
	}
};